﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;


public partial class indexlyb : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        tbIP.Text = Request.UserHostAddress;
        if (!Page.IsPostBack)
        {
            BindPageData();
        }

        sm.RegisterAsyncPostBackControl(tbMessage);	
    }
    private void BindPageData()
    {   ///获取数据
        Class1 message = new Class1();
        DataSet ds = message.GetMessages();
        ///显示数据
        gvMessage.DataSource = ds;
        gvMessage.DataBind();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        tbMessage.Text = string.Empty;
    }
    protected void btnCommit_Click1(object sender, EventArgs e)
    {
        Class1 cc=new Class1();
        if (cc.AddMessage(tbTitle.Text, tbMessage.Text, Request.UserHostAddress, tbEmail.Text) > 0)
        {
            BindPageData();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("guanli.aspx");
    }
}